//
//  B_TopicDetailGoodsTVC.m
//  DreamOf
//
//  Created by 薛小刚 on 2018/9/11.
//  Copyright © 2018年 薛小刚. All rights reserved.
//

#import "B_TopicDetailGoodsTVC.h"
#import "B_TopicGoodsCVC.h"
#import "B_TopicDetailBasicModel.h"

@implementation B_TopicDetailGoodsTVC

- (void)awakeFromNib {
    [super awakeFromNib];
    [self.B_collectionView registerNib:[UINib nibWithNibName:@"B_TopicGoodsCVC" bundle:nil] forCellWithReuseIdentifier:@"B_TopicGoodsCVC"];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setGoodsArray:(NSArray *)goodsArray {
    _goodsArray = goodsArray;
    [self.B_collectionView reloadData];
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    B_TopicGoodsCVC * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"B_TopicGoodsCVC" forIndexPath:indexPath];
    B_TopicAboutGoodsModel * model = self.goodsArray[indexPath.row];
    [cell.B_goodsImageView sd_setImageWithURL:[NSURL URLWithString:model.goodsImg]];
    cell.B_titleLabel.text = model.goodsName;
    cell.B_priceLabel.text = [NSString stringWithFormat:@"¥%@", model.goodsPrice];
    return cell;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.goodsArray.count;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    if (self.collectionTapAction) {
        self.collectionTapAction(indexPath);
    }
}

//- (CGSize) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
//    　CGFloat width = (SCREEN_WIDTH - 4) / 4.;
//    return CGSizeMake(width, width + 1);
//}


@end
